import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/net/api/http_api.dart';
import 'package:ls_work/net/post_request.dart';

import '../net/response/employee_data_list.dart';
import '../net/response/temp_human_data_list.dart';

class EmployeeModel extends BaseMvvmModel{
  @override
  void onCleared() {
  }


  Future<List<EmployeeDataList>> employeeList(String nameLike,{int page = 1,int rows = 20,dynamic officeId}) async {
    var map = {
      "nameLike":nameLike,
      "page":page,
      "rows":rows
    };
    if(officeId!=null){
      map['officeId'] = officeId;
    }
    var data = await HttpGo.instance.postData(BookFoodApis.employeeList,data: map,options: PostRequest.urlencodedHeader);
    if("0"==data['code']){
      var list = ((data['data']['rows'] as List)??[]).map((e) => EmployeeDataList.fromJson(e)).toList();
      return list;
    }else{
      throw data['msg'];
    }
  }

  Future<List<TempHumanDataList>> tempList({String nameLike = ""}) async {
    var map = {
      "nameLike":nameLike
    };
    var data = await HttpGo.instance.postData(BookFoodApis.tempList,data: map.toJsonMapStr(),options: PostRequest.urlencodedHeader);
    if("0"==data['code']){
      var list = ((data['data'] as List)??[]).map((e) => TempHumanDataList.fromJson(e)).toList();
      return list;
    }else{
      throw data['msg'];
    }
  }


}